<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品档案登记</title>
    <link rel="stylesheet" href="../../css/pintuer.css">
    <link rel="stylesheet" href="../../css/admin.css">
    <link rel="stylesheet" href="../../css/bootstrap.css">
    <style>
        input{
            border-top: none;
            border-left: none;
            border-right: none;
            border-bottom: black solid 1px;
        }
        table{
            border: 1px;
            cell-padding:0;
            cell-spacing:0;
            width: 80%;
            margin-top: 20px;
        }
        table thead{
            background-color:#b3d7ff ;
        }
        a{
            cursor: pointer;
        }
    </style>
</head>
<body bgcolor="#f5f5f5">
<script src="../../js/jquery-3.4.1.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script>
    function initI(){
        $.ajax({
            url:'/dConfig/selectDconfigAll.action',
            type:'get',
            data:'level=1',
            dataType:'json',
            success:function (data) {
                var sel = $('select[name="FIRST_KIND_ID"]');
                // sel.empty();
                for (var i=0;i<data.length;i++){
                    var opt =  $('<option>').text(data[i].kindId+"-"+data[i].kindName);
                    opt.val(data[i].id);
                    sel.append(opt);
                }
            }
        })
    }
    function initII(){
        var sid = $('select[name="FIRST_KIND_ID"]').val();
        $.ajax({
            url:'/dConfig/selectDconfigAll.action',
            type:'get',
            data:'level=2',
            dataType:'json',
            success:function (data) {
                var sel = $('select[name="SECOND_KIND_ID"]');
                sel.empty();
                for(var i = 0 ; i<data.length; i++){
                    if(data[i].pId==sid){
                        var opt =  $('<option>').text(data[i].kindId+"-"+data[i].kindName);
                        opt.val(data[i].id);
                        sel.append(opt);
                    }
                }
            }
        });


    }
    function initIII(){

        var sid = $('select[name="SECOND_KIND_ID"]').val();
        $.ajax({
            url:'/dConfig/selectDconfigAll.action',
            type:'get',
            data:'level=3',
            dataType:'json',
            success:function (data) {
                var sel = $('select[name="THIRD_KIND_ID"]');
                sel.empty();
                for(var i = 0 ; i<data.length; i++){
                    if(data[i].pId==sid){
                        var opt =  $('<option>').text(data[i].kindId+"-"+data[i].kindName);
                        opt.val(data[i].id);
                        sel.append(opt);
                    }
                }
            }
        });


    }
    $(function () {
        initI();
        var myDate = new Date;
        var year = myDate.getFullYear(); //获取当前年
        var mon = myDate.getMonth() + 1; //获取当前月
        var date = myDate.getDate(); //获取当前日
        var h = myDate.getHours();//获取当前小时数(0-23)
        var m = myDate.getMinutes();//获取当前分钟数(0-59)
        var s = myDate.getSeconds();//获取当前秒
        $('#REGISTER_TIME').text(year+"-"+mon+'-'+date+' '+h+':'+m+':'+s);
        $("#REGISTER").text(localStorage.getItem("userName"));
        // $("#otherInfo + tr").css("display","none");

        $('#sub_btn').click(function () {
            var r = window.confirm("请问您是否要添加该产品");
            if(r){
                var frm = $('#frm').serialize();
                frm = decodeURIComponent(frm,true);
                var f_name = $('select[name="FIRST_KIND_ID"]').find("option:selected").text();
                var s_name = $('select[name="SECOND_KIND_ID"]').find("option:selected").text();
                var t_name = $('select[name="THIRD_KIND_ID"]').find("option:selected").text();
                $.ajax({
                    url:'/dFile/addProduct',
                    type:'post',
                    data:frm+'&firstName='+f_name+'&secondName='+s_name+'&thirdName='+t_name,
                    success:function (data) {
                        if(data>0){
                            alert("登记成功！");
                            window.location="addProduct.html";
                        }
                    }
                })
            }
        });
       /* $("#otherInfo").click(function () {
            $("#otherInfo + tr").css("display","block");
        })*/
    })
</script>
    <div class="container-fluid">
        <div style="background-color: lightgray;width: 100%; margin-top: 0px;padding-top: 0px;">
        </div>
        <div style="width: 80%;position: absolute;left: 50px;">
            <div class="row" style="height: 20% ;">
                <div class="col-8"></div>
                <div class="col-2"></div>
                <div class="col-2" >
                    <button class="btn" id="sub_btn" style="background-color: cornflowerblue">提交</button>
                </div>

            </div>
            <form id="frm">
                <table  class="table">
                 <tr>
                    <td colspan="4"><div style="margin: 0px;padding: 0px; background-color: #5b81bb"><span style="color: #eeffff">主信息</span></div></td>
                 </tr>
                 <tr>
                     <td><span style="color: black;">产品名称：</span></td>
                     <td><input type="text" name="PRODUCT_NAME"></td>
                     <td><span style="color: black;">制造商：</span></td>
                     <td><input type="text" name="FACTORY_NAME"></td>
                 </tr>
                  <tr>
                      <td><span style="color: black;">I级分类：</span></td>
                      <td><select name="FIRST_KIND_ID" onchange="initII();">
                          <option value="00">--------请选择--------</option>
                      </select></td>
                      <td><span style="color: black;">II级分类：</span></td>
                      <td><select name="SECOND_KIND_ID" onchange="initIII();">
                          <option value="00">--------请选择--------</option>
                      </select></td>
                  </tr>

                    <tr>
                        <td><span style="color: black;">III级分类：</span></td>
                        <td><select name="THIRD_KIND_ID">
                            <option value="00">--------请选择--------</option>
                        </select></td>
                        <td><span style="color: black;">产品简称：</span></td>
                        <td><input type="text" name="PRODUCT_NICK"/></td>
                    </tr>

                    <tr>
                        <td><span style="color: black;">用途类型：</span></td>
                        <td><select name="TYPE">
                            <option>--------请选择-------</option>
                            <option value="Y001-1">商品</option>
                            <option value="Y001-2">物料</option>
                        </select></td>
                        <td><span style="color: black;">档次级别：</span></td>
                        <td><select name="PRODUCT_CLASS">
                            <option>--------请选择--------</option>
                            <option value="D001-1">高档</option>
                            <option value="D001-2">中档</option>
                            <option value="D001-3">低档</option>
                        </select></td>
                    </tr>
                    <tr>
                        <td><span style="color: black;">计量单位：</span></td>
                        <td><input type="text" name="PERSONAL_UNIT"></td>
                        <td><span style="color: black;">计量值：</span></td>
                        <td><input type="text" name="PERSONAL_VALUE"></td>
                    </tr>
                    <tr>
                        <td><span style="color: black;">市场单价（元）：</span></td>
                        <td><input type="text" name="LIST_PRICE"></td>
                        <td><span style="color: black;">计划成本单价（元）：</span></td>
                        <td><input type="text" name="COST_PRICE"></td>
                    </tr>
                    <tr id="otherInfo">
                        <td colspan="4"><div style="margin: 0px;padding: 0px; background-color: #5b81bb"><span style="color: #eeffff">辅助信息</span></div></td>
                    </tr>

                    <tr>
                        <td><span style="color: black;">保修期：</span></td>
                        <td><input type="text" name="WARRANTY"></td>
                        <td><span style="color: black;">替代品名称：</span></td>
                        <td><input type="text" name="TWIN_NAME"></td>
                    </tr>
                    <tr>
                        <td><span style="color: black;">替代品编号：</span></td>
                        <td><input type="text" name="TWIN_ID"></td>
                        <td><span style="color: black;">生命周期（年）：</span></td>
                        <td><input type="text" name="LIFECYCLE"></td>
                    </tr>
                    <tr>
                        <td><span style="color: black;">单位：</span></td>
                        <td><input type="text" name="AMOUNT_UNIT"></td>
                        <td><span style="color: black;">产品经理：</span></td>
                        <td><select name="RESPONSIBL_PERSON">
                            <option value="老夏">老夏</option>
                            <option value="许某">许某</option>
                            <option value="小刘">小刘</option>
                        </select></td>
                    </tr>
                    <tr>
                        <td><span style="color: black;">供应商集合：</span></td>
                        <td><textarea  name="PROVIDER_GROUP"></textarea></td>
                        <td><span style="color: black;">产品描述：</span></td>
                        <td><textarea  name="PRODUCT_DESCRIBE"></textarea></td>
                    </tr>
                    <tr>
                        <td><span style="color: black;">登记人：</span></td>
                        <td><span  id="REGISTER"></span></td>
                        <td><span style="color: #000000;">建档时间：</span></td>
                        <td><span id="REGISTER_TIME"></span></td>
                    </tr>
                </table>
            </form>
        </div>

    </div>
</body>
</html>